#!/usr/bin/env python

import ConfigParser,sys,mylog,deploy

logger=mylog.initlog('init deploy',1)

cf=ConfigParser.ConfigParser()
cf.read("../config/craneWeb.conf")

username=cf.get("user","username")
password=cf.get("user","password")
master=cf.get("master","host")
masterpass=cf.get("master","rootpass")
slave1=cf.get("slave1","host")
slave1pass=cf.get("slave1","rootpass")

logger.debug(username)
logger.debug(password)
logger.debug(master)
logger.debug(masterpass)
logger.debug(slave1)
logger.debug(slave1pass)

deploy.nfsConf(master,masterpass,slave1,logger)
deploy.nfsExport(master,masterpass,logger)
deploy.mountSlave(slave1,slave1pass,master,logger)
deploy.fstabConf(slave1,slave1pass,master,logger)
deploy.createUser(master,masterpass,username,password,logger)
deploy.loadBalanceConf(master,masterpass,slave1,logger)
deploy.loadBalanceStart(master,masterpass,logger)
deploy.phpmyadminConf(master,masterpass,logger)
deploy.mysqlAddUser(master,masterpass,username,password,1,logger)

message = "User Name: %s\n\
 Password: %s\n\
  Web URL: http://%s\n\
      FTP: %s\n\
    MySQL: http://%s/craneutility/phpmyadmin" % (username, password, master, master, master)

print message

f = open('../userInfo/'+username, 'w')
f.write(message)
f.close()
